import http from "./http";
import qs from "qs";
import md5 from "js-md5";
import { decrypt } from '@/utils'

export const setToken = (token) => {
  http.setToken(token);
}
export const setXToken = (xtoken) => {
  http.setXToKen(xtoken);
}
// 登录
export const login = (params={}) => {
  return http.post("/manager/sys/login", qs.stringify(params));
}
// 在线状态
export const robotT = () => {
  return http.get("/t?_"+Date.now())
}
// 验证码
export const captcha = (random) => {
  setXToken(random)
  return ( process.env.REACT_APP_BASEURL + "/manager/sys/captcha?randomStr=" + random );
}
// 是否绑定谷歌验证器
export const checkBind = (params={}) => {
  return http.get("/google/checkBind", params);
}
// 获取谷歌验证器密钥与二维码
export const secret = (params={}) => {
  return http.get("/google/secret", params);
}
// 重置谷歌验证器-当前账号
export const reset = (params={}) => {
  return http.post("/google/reset", qs.stringify(params));
}
// 绑定谷歌验证器
export const bind = (params={}) => {
  return http.post("/google/bind", qs.stringify(params));
}
// eslint-disable-next-line import/no-anonymous-default-export
export default {
  setToken,
  setXToken,
  // 登录
  login,
  // 验证码
  captcha,
  
  checkBind,
  secret,
  reset,
  bind,
};
